<template>
  <div class="app-agent">
    <br>
    <el-form ref="queryParams" size="small" :inline="true" label-width="160px" v-model="queryParams" v-show="showSearch">
      <el-form-item label="手机号" prop="phone">
        <el-input placeholder="请输入手机号" v-model="queryParams.phone" />
      </el-form-item>

      <el-form-item label="昵称" prop="nickName">
        <el-input placeholder="请输入昵称" v-model="queryParams.nickName" />
      </el-form-item>

      <el-form-item label="审核状态" prop="status">
        <el-select v-model="searchStatus" placeholder="请选择审核状态" clearable>
          <el-option label="待审核" value="0"></el-option>
          <el-option label="机审审核通过" value="1"></el-option>
          <el-option label="机审审核失败" value="2"></el-option>
          <el-option label="机审通过人工审核通过" value="3"></el-option>
          <el-option label="机审通过人工审核失败" value="4"></el-option>
          <el-option label="人工确认" value="5"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>

    </el-form>
    <!-- 新增 -->
    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 表格 -->
    <el-table v-loading="loading" :data="userDataList" @selection-change="handleSelectionChange" label-width="100px">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->

      <el-table-column label="手机号" align="center" prop="phone" width="150"/>
      <el-table-column label="昵称" align="center" prop="nickName" />
      <el-table-column label="音频/视频" align="center" prop="content">

  <template slot-scope="scope">
    <el-button type="primary" @click="openModal(scope.row.content)">播放</el-button>
  </template>
      </el-table-column>


      <el-table-column label="审核状态" align="center" prop="examine">
        <template slot-scope="scope">
          <span>{{ scope.row.examine == 0?"待审核":scope.row.examine == 1?"机审审核通过":scope.row.examine == 2?"机审审核失败":scope.row.examine == 3?"机审通过人工审核通过":scope.row.examine == 4?"机审通过人工审核失败":scope.row.examine == 5?"人工确认":null }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['system:musicinfo:edit']">{{ scope.row.examine ==3?"修改":scope.row.examine ==4?"修改":"审核" }}</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 视频 -->
    <el-dialog :visible.sync="videoModal" width="50%" 
    :before-close="handleClose">
      <div class="videoInfo">
    <video :src="videoSrc" controls autoplay></video>
  </div>

</el-dialog>

        <!-- 审核对话框 -->
        <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="queryParams" :model="queryParams"  label-width="80px">

        <el-form-item label="是否通过">
          <el-radio-group v-model="queryParams.status">
            <el-radio :label="3">人工审核通过</el-radio>
            <el-radio :label="4">人工审核失败</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

  </div>
</template>

<script>
import { getAudit,upDatainfo,upDataBackground } from "../../../api/system/dataReview"
import { regionData } from "../../../../node_modules/element-china-area-data";
export default {
  name: 'measurementReview',
  // dicts: ['content_type'],
  data() {
    return {
      searchStatus: null,
      videoModal: false,
    videoSrc: '',
      // right:right,
      // 遮罩层
      loading: true,
       // 总条数
       total: 1,
      // 用户表格数据
      userDataList: [],
       // 是否显示弹出层
       open: false,
        // 弹出层标题
      title: "",
      // 显示隐藏二级
      isFlag: false,

      multiple:true,

      form:{},
      // 显示搜索条件
      showSearch: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        nickName:null,
        phone:null,
        status:null,
        startTime:null,
        endTime:null,
        id:null,
        createTime:null,
      },
    }
  },
  created() {
    this.getList();
  },
  methods: {
    openModal(src) {
    this.videoSrc = src;
    this.videoModal = true;
  },
  handleClose() {
    this.videoModal = false;
    this.videoSrc = '';
  },
      // 取消按钮
      cancel() {
      this.open = false;
      this.reset();
    },

     // 表单重置
     reset() {
      this.form = {
            // createTime: null,
            // examine: null,
            // phone: null,
            // nickName: null,
            // id: null,
            // contentTitle:null,
            // content:null,
            // createTime:null,
            // userId:null,
            // endTime:null,
            // avatar: null,
            // userId: null,
            // auditAvatar: null,
            // operation: null,
            // introduction:null
            id	:null,
userId	:null,
examine	:null,
createTime	:null,
updateTime	:null,
type	:null,
content	:null,
musicName	:null,
operation	:null,
name	:null,
recordId	:null,
phone	:null,
nickName:null,
      };
      this.resetForm("form");
    },
     /** 查询内容模块列表 */
     getList() {
      this.loading = true;
      getAudit(this.queryParams).then(response => {
        this.userDataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

     // 多选框选中数据
     handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
   
     /** 搜索按钮操作 */
     handleQuery() {
      this.queryParams.pageNum = 1;
      this.queryParams.status = this.searchStatus;
      this.getList();
    },

      /** 重置按钮操作 */
    //   resetQuery() {
    //   this.resetForm("queryForm");
    //   this.handleQuery();
    // },

    resetQuery() {
  this.queryParams = {
    pageNum: 1,
    pageSize: 10,
    nickName: null,
    phone: null,
    status: null,
    startTime: null,
    endTime: null,
    id: null,
    createTime: null,
  };
  this.searchStatus = null; 
  this.handleQuery();
},

     /** 修改按钮操作 */
     handleUpdate(row) {
      this.reset();
      // const id = row.id || this.ids
      this.open = true;
      this.queryParams.id = row.id;
      this.queryParams.status = row.examine;
    },


       /** 提交按钮 */
    submitForm() {
      this.$refs["queryParams"].validate(valid => {
        const { id, status } = this.queryParams;
        if (valid) {
          if (this.queryParams.status == 3 || this.queryParams.status == 4) {
            upDatainfo({id:id,status:status}).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.this.queryParams.status = null
              this.getList();
            });
          } else {
            upDataBackground({id:id,status:status}).then(response => {
              this.$modal.msgSuccess("审核成功");
              this.open = false;
              this.this.queryParams.status = null
              this.getList();
            });
          }
        }
      });
    },
  }

}
</script>

<style scoped>

.on_border_input >>> .el-input__inner {
  border: 0px;
}
.on_border_select >>> .el-input__inner {
  border: 0px;
  /* color: blue; */
  font-size: 12px;
}
.videoInfo{
  display: flex; justify-content: center; align-items: center; height: 100%;
}
video{
  max-width: 100%; max-height: 60vh;
}
</style>